﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Bytecode;
using Microsoft.Practices.Unity;
using NHibernate.Bytecode.Lightweight;
using NHibernate.Properties;
using NHibernate.ByteCode.Castle;

namespace IISDeploy.Data.Interceptor
{
    public class UnityBytecodeProvider : IBytecodeProvider
    {
        private readonly IObjectsFactory objectsFactory = new ActivatorObjectsFactory();
        private readonly IUnityContainer container;

        public UnityBytecodeProvider(IUnityContainer container)
        {
            this.container = container;
        }

        public IReflectionOptimizer GetReflectionOptimizer(Type clazz, IGetter[] getters, ISetter[] setters)
        {
            return new ReflectionOptimizer(container, clazz, getters, setters);
        }

        public IProxyFactoryFactory ProxyFactoryFactory
        {
            get { return new ProxyFactoryFactory(); }
        }

        public IObjectsFactory ObjectsFactory
        {
            get { return objectsFactory; }
        }


        #region IBytecodeProvider Members

        public ICollectionTypeFactory CollectionTypeFactory
        {
            get { return null; }
        }

        #endregion
    }
}
